#include <iostream>
#include <stdlib.h>

#define LOG "log.txt"
#define SIZE 32

int main()
{
    FILE* fp = fopen(LOG, "w");
    if(!fp) {
        perror("fopen file fail!");
        exit(-1);
    }

    char buffer[SIZE];
    int cnt = 5;
    while(cnt--) {
        snprintf(buffer, SIZE, "%s\n", "hello Lixx");
        fputs(buffer, fp);
    }
    fclose(fp);
    fp = nullptr;
    return 0;
}